import time

from retrying import retry

num = 1


@retry(stop_max_attempt_number=3)
def test():
    global num
    print("num=", num)
    num += 1
    time.sleep(1)
    for i in 100:
        print("i", i)


if __name__ == '__main__':
    try:
        test()
    except Exception as ret:
        print("产生异常...")
        print(ret)
    else:
        print("没有异常")
